﻿namespace SAD.DataCenter
{
    using System;
    using System.Collections.Generic;
    using SAD.DataCenter.InfoSources;
    using SAD.Common.Models;
    using SAD.DataCenter.InfoSources.SMS;

    public class InfoSourceManager
    {
        private List<IInfoSource> m_InfoRecvicesByOrder = new List<IInfoSource>();

        #region Instance
        /// <summary>
        /// 类型单例
        /// </summary>
        public static InfoSourceManager Instance
        {
            get
            {
                return m_Instance;
            }
        }
        private static InfoSourceManager m_Instance = new InfoSourceManager();
        #endregion

        private InfoSourceManager()
        {
            IInfoSource source = new SMSInfoSource();
            source.Init(this);

            m_InfoRecvicesByOrder.Add(source);
        }

        internal void Start()
        {
            foreach (IInfoSource source in m_InfoRecvicesByOrder)
            {
                source.Start();
            }
        }

        internal void Stop()
        {
            foreach (IInfoSource source in m_InfoRecvicesByOrder)
            {
                source.Stop();
            }
        }

        internal void NewInfoProcess(Info_Data info)
        {
            InfoManager.Instance.SendInfo(info);
        }
    }
}